<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles-extras" prefix="tilesx" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="tag"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="security"%>

<script type="text/javascript">
	function openSaveChangesDialog()
	{
	  afterFieldEdit('<spring:message code="field.supplier.name"/>', 'string', 'mamSupLookUp.supId', 'false', new Array());
	  afterFieldEdit('<spring:message code="field.mam.name"/>', 'string', 'mamSupLookUp.mamId', 'false', new Array());
	  setTimeout("checkErrorsForSaveChangesDialog()", 100);
	}

	function enableSave()
	{
		if ($(parseIdForJQuery("mamSupLookUp.supId")).val() != ''
				&& $(parseIdForJQuery("mamSupLookUp.mamId")).val() != '')
		{
			var saveButton = $("#saveButton");
			saveButton.click(function()
			{
				openSaveChangesDialog();
			});
			saveButton.mouseover(function()
			{
				buttonHover(this);
			});
			saveButton.mouseout(function()
			{
				buttonNormal(this);
			});
			saveButton.addClass("button_input").removeClass(
					"button_inputDisabled");
		}
	}

	function updateChange()
	{
		if (changeCountField != null)
		{
			changeCountField.value = parseInt(changeCountField.value) + 1;
			checkButtons(changeCountField.value);
		}
	}
</script>

<form id="adminForm" name="adminForm" method="post">

	<form:hidden path="adminCommand.adminRequestedAction" id="adminCommand.adminRequestedAction" />
	<form:hidden path="adminCommand.isNew" id="adminCommand.isNew" />
	<form:hidden path="adminCommand.mamSupLookUp.pk" id="adminCommand.mamSupLookUp.pk" />
	<input type="hidden" id="callStatus" name="callStatus" value=""/>
	<tag:errors name="adminCommand" />

	<table>
		<jsp:include page="/pages/jsp/tiles/admin/errors.jsp" />
	</table>

	<table align="center">
	  <tr>
	    <td>
		  <table class="adminEdit" align="center">

		    <tr>
              <th align="center" width="200px"><spring:message code="field.supplier.name"/></th>
              <security:authorize ifAllGranted="ROLE_EDITABLE">
              <spring:bind path="adminCommand.mamSupLookUp.supId">
			  <td width="400px">
			    <input type="hidden" id="${status.expression}_originalValue" name="${status.expression}_originalValue" value="${status.value}"/>
			    <input type="text" id="${status.expression}" name="${status.expression}"
					   value="${status.value}" tabindex="1" class="smallTextField" maxlength="4"
					   onkeyup="fieldEdit('${status.expression}');"
					  onchange="afterFieldEdit('<spring:message code="field.supplier.name"/>', 'string', '${status.expression}', 'false', new Array());" />&nbsp;*
				<div id="${status.expression}_errorField" class="errorText" style="visibility: hidden; display: none;"></div>
			  </td>
			  </spring:bind>
              </security:authorize>
              <security:authorize ifNotGranted="ROLE_EDITABLE">
              <td width="400px">${adminCommand.mamSupLookUp.supId}</td>
              </security:authorize>
		    </tr>

		    <tr>
              <th align="center" width="200px"><spring:message code="field.mam.name"/></th>
		      <security:authorize ifAllGranted="ROLE_EDITABLE">
              <spring:bind path="adminCommand.mamSupLookUp.mamId">
			  <td width="400px">
			    <input type="hidden" id="${status.expression}_originalValue" name="${status.expression}_originalValue" value="${status.value}" />
			    <input type="text" id="${status.expression}" name="${status.expression}"
					   value="${status.value}" tabindex="2" class="smallTextField" maxlength="4"
					   onkeyup="fieldEdit('${status.expression}');"
					   onchange="afterFieldEdit('<spring:message code="field.mam.name"/>', 'string', '${status.expression}', 'false', new Array());" />&nbsp;*
				<div id="${status.expression}_errorField" class="errorText" style="visibility: hidden; display: none;"></div>
			  </td>
		      </spring:bind>
              </security:authorize>
              <security:authorize ifNotGranted="ROLE_EDITABLE">
              <td width="400px">${adminCommand.mamSupLookUp.mamId}</td>
              </security:authorize>
		    </tr>
		  </table>
		</td>
	  </tr>
	  <tr>
		<td>
		  <table align="center" style="margin-top: 10px;">
			<tr>
			  <td style="text-align: center;"><jsp:include page="/pages/jsp/tiles/admin/supportedMapEditButtons.jsp" /></td>
			</tr>
		  </table>
		</td>
	  </tr>
	  <jsp:include page="/pages/jsp/tiles/admin/hoverConfirmation.jsp" />
	</table>